package day05;

import java.util.Arrays;
import java.util.Random;

//此类是用于验证数组取最大值的测试Demo
public class MaxOfArray {
    public static void main(String[] args) {
        /*Random rand = new Random();
        int[] arr = new int[10];
        int max = 0;
        for (int i = 0; i < arr.length; i++) {
            arr[i] = rand.nextInt(100);
            if (arr[i] > max) {
                max = arr[i];
            }
            System.out.print(arr[i] + " ");
        }
        System.out.println();
        System.out.println(max);
        Arrays.sort(arr);
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i] + " ");
        }
        System.out.println();
        System.out.println(arr[arr.length - 1]);*/
        //冒泡排序
        int[] arr = new int[10];
        Random rand = new Random();
        int num = arr[0];
        for (int i = 0; i < arr.length; i++) {
            arr[i] = rand.nextInt(100);
            if (arr[i] > num) {
                num = arr[i];
            }
        }
        System.out.println(arr);
        System.out.println(Arrays.toString(arr));
        System.out.println("数组arr中最大的元素为" + num);
    }
}

